package org.dark.streamweb;

import org.apache.ibatis.session.SqlSessionFactory;
import org.dromara.streamquery.stream.core.clazz.ClassHelper;
import org.dromara.streamquery.stream.plugin.mybatisplus.engine.mapper.DynamicMapperHandler;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;

import java.util.List;

@ComponentScan(basePackages = {"org.dark"})
@SpringBootApplication
public class StreamWebApplication {

	public static void main(String[] args) {
		SpringApplication.run(StreamWebApplication.class, args);
	}


	@Bean
	public DynamicMapperHandler dynamicMapperHandler(SqlSessionFactory sqlSessionFactory) throws Exception {
		// 使用ClassHelper的scanClasses方法扫描对应路径下的po生成Class文件集合放入第二个参数就可以了
		final List<Class<?>> entityClassList= ClassHelper.scanClasses("org.dark.streamweb.demo.po");
		return new DynamicMapperHandler(sqlSessionFactory,entityClassList);
	}

}
